package com.zyk.leetcode;

import java.util.ArrayList;
import java.util.LinkedList;
import java.util.List;

/**
 * @author zhangsan
 * @date 2021/4/12 15:01
 */
public class M0804 {

    List<List<Integer>> ans = new ArrayList<>();
    LinkedList<Integer> elements = new LinkedList<>();

    public List<List<Integer>> subsets(int[] nums) {
        process(nums, 0);
        return ans;
    }

    private void process(int[] nums, int i) {
        if (i == nums.length) {
            ans.add(new ArrayList<>(elements));
            return;
        }
        elements.add(nums[i]);
        process(nums, i + 1);
        elements.removeLast();
        process(nums, i + 1);
    }


    public static void main(String[] args) {
        M0804 test = new M0804();

        int[] nums = {1, 2, 3};
        List<List<Integer>> ans = test.subsets(nums);
        System.out.println(ans);
    }

}
